// 提供商品相关的API

import request from '@/utils/request'

export const findGoods = (id) => {
  return request('/goods', 'get', { id })
}

/**
 * 获取商品同类推荐 | 猜你喜欢
 * @param id 商品id，传入是相关推荐，未传入id为猜喜欢
 * @param limit
 * @returns {*|AxiosPromise}
 */
export const findGoodsRelevant = (id, limit) => {
  return request('/goods/relevant', 'get', {
    id,
    limit
  })
}

/**
 * 获取热销推荐数据
 * @param id
 * @param limit
 * @param type
 * @returns {*|AxiosPromise}
 */
export const findHotGoods = (id, type = 1, limit = 3) => {
  return request('/goods/hot', 'get', {
    id,
    limit,
    type
  })
}

/**
 * 获取商品的评价统计信息
 * @param {String} id - 商品ID
 */
export const findCommentInfoByGoods = (id) => {
  // return request(`/goods/${id}/evaluate`, 'get')
  // axios遇见http https开头的地址不会加上基准地址
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate`, 'get')
}
// https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate

/**
 * 查询商品评价列表
 * @param id 商品id
 * @param params 查询参数
 * @returns {*|AxiosPromise}
 */
export const findCommentListByGoods = (id, params) => {
  // return request(`/goods/${id}/evaluate/page`, 'get')
  // axios遇见http https开头的地址不会加上基准地址
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate/page`, 'get', params)
}
